<template>
  <!-- 首页 -->
  <div class="dashboard-container">
    <div class="dashboard-text">{{ a }}</div>
    <div class="dashboard-text">{{ b }}</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { getnumberReport } from '@/api/user'
import { getToken } from '@/utils/auth'
export default {
  name: 'Dashboard',
  data() {
    return {
      a: '未登录,请先登录',
      b: ''
    }
  },
  computed: {
    ...mapGetters([
      'name'
    ])
  },
  created() {
    if (this.$store.state.user.name !== null) {
      this.a = this.$store.state.user.name + '  欢迎使用电子产品质量检测系统 '
      getnumberReport({ ReportPeople: getToken().substring(1) }).then((Response) => {
        if (Response.data.length === 0) {
          if (getToken.substring(0, 1) === 'T') {
            this.b = '报告已经全部处理完了，你真牛逼'
          }
        } else {
          this.b = '你有' + Response.data.length + '个报告未处理，请及时处理'
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 25px;
    line-height: 46px;
  }
}
</style>
